package com.mshop.service;

import com.mshop.fw.modules.CommonService;
import com.mshop.po.Users;
import com.mshop.util.QL;

public class UsersService extends CommonService {
	public Users findByNamePwd(String name, String pwd) {
		Users users = dao.findSingle(Users.class, QL.HQL.Users.FIND_BY_NAME,
				new Object[] { name });
		if (users != null) {
			String pass = users.getPwd();
			if (pass != null && pass.equals(pwd)) {
				return users;
			} else {
				return null;
			}
		}
		return users;
	}
	
	public Users findByName(String name) {
		Users users = dao.findSingle(Users.class, QL.HQL.Users.FIND_BY_NAME,
				new Object[] { name });
		return users;
	}
	
	public void save(Users users) {
		dao.save(users);
	}

	public Users load(String id) {
		return dao.load(Users.class, new Long(id));
	}
	
	public Users get(String id) {
		return dao.get(Users.class, new Long(id));
	}

	public void delete(String id) {
		dao.delete(this.get(id));
	}
}
